/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package carstoredb.models;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author wuhao
 */
@Entity
@Table(name = "ORDER_INFO")
@XmlRootElement
@NamedQueries({
	@NamedQuery(name = "OrderInfo.findAll", query = "SELECT o FROM OrderInfo o"),
	@NamedQuery(name = "OrderInfo.findByOrderId", query = "SELECT o FROM OrderInfo o WHERE o.orderId = :orderId"),
	@NamedQuery(name = "OrderInfo.findByOrderTime", query = "SELECT o FROM OrderInfo o WHERE o.orderTime = :orderTime"),
	@NamedQuery(name = "OrderInfo.findByStatus", query = "SELECT o FROM OrderInfo o WHERE o.status = :status")})
public class OrderInfo implements Serializable {

	private static final long serialVersionUID = 1L;
	@Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Basic(optional = false)
        @Column(name = "ORDER_ID")
	private Integer orderId;
	@Column(name = "ORDER_TIME")
        @Temporal(TemporalType.TIMESTAMP)
	private Date orderTime;
	@Column(name = "status")
	private Integer status;
	@JoinColumn(name = "STORE_ID", referencedColumnName = "STORE_ID")
        @ManyToOne
	private Carstore storeId;
	@JoinColumn(name = "USER_ID", referencedColumnName = "USER_ID")
        @ManyToOne
	private User userId;
	@JoinColumn(name = "car_ID", referencedColumnName = "ID")
        @ManyToOne
	private Car carID;

	public OrderInfo() {
	}

	public OrderInfo(Integer orderId) {
		this.orderId = orderId;
	}

	public Integer getOrderId() {
		return orderId;
	}

	public void setOrderId(Integer orderId) {
		this.orderId = orderId;
	}

	public Date getOrderTime() {
		return orderTime;
	}

	public void setOrderTime(Date orderTime) {
		this.orderTime = orderTime;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Carstore getStoreId() {
		return storeId;
	}

	public void setStoreId(Carstore storeId) {
		this.storeId = storeId;
	}

	public User getUserId() {
		return userId;
	}

	public void setUserId(User userId) {
		this.userId = userId;
	}

	public Car getCarID() {
		return carID;
	}

	public void setCarID(Car carID) {
		this.carID = carID;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (orderId != null ? orderId.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof OrderInfo)) {
			return false;
		}
		OrderInfo other = (OrderInfo) object;
		if ((this.orderId == null && other.orderId != null) || (this.orderId != null && !this.orderId.equals(other.orderId))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "carstoredb.models.OrderInfo[ orderId=" + orderId + " ]";
	}
	
}
